joystick object
This function returns a list of all the buttons on the joystick that are currently being held down.
int[] buttons_down()
Parameters:
None.
Return value:
An array with the currently held buttons, or an empty array if no buttons are being held down or if an error occurs.
Remarks:
The difference between buttons_down and buttons_pressed is that buttons_pressed will only return a list of the buttons that the user has just pushed down, while buttons_down will return a list of the buttons that are currently being held down regardless of whether the same buttons have been reported as being down in a previous call.
The joystick object supports up to 128 buttons, ranging from 0 to 127. However the actual maximum button is determined by the buttons property for the given device, ranging from 0 to buttons minus 1.
It is important to remember when mapping functions to joystick buttons that devices can vary greatly between models, supporting anything between 3 and 15 buttons, and therefore it is always a good idea to map the most common activities to buttons with lower numbers.
Example:
// Wait for three different buttons to be held down at once before closing the program.
void main()
{
show_game_window("buttons Down Test");
int[] button_list;
joystick stick;
if(stick.joysticks==0)
{
alert("Error", "No joysticks seem to be attached.");
exit();
}
while(button_list.length()<3)
{
button_list=stick.buttons_down();
wait(5);
}
}